package ch10_10_4;
public class House implements Cloneable, Comparable<Object>{
	private int id;
	private double area;
	private java.util.Date whenBuilt;
	
	public House(int id, double area){
		this.id=id;
		this.area=area;
		whenBuilt=new java.util.Date();
	}
	
	public double getId(){
		return id;
	}
	
	public double getArea(){
		return area;
	}
	
	public java.util.Date getWhenBuilt(){
		return whenBuilt;
	}
	
	/** override the protected clone method defined in the Object
	 * class, and strengthen its accessibility */
	public Object clone(){
		House h=null;
		try{
			h=(House)super.clone();
		}
		catch(CloneNotSupportedException e)
        {
            System.out.println(e.toString());
        }
		h.whenBuilt=whenBuilt;
		return h;
	}
	
	/** Implement the compareTo method defined in Comparable */
	public int compareTo(Object o) {
		if(area > ((House)o).area)
			return 1;
		else if(area < ((House)o).area)
			return -1;
		else
			return 0;
	}
	
}